package com.jxpanda.spring.module.wechat.component.http.base.response;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.jxpanda.spring.module.wechat.component.http.base.WechatHttpResponse;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;

/**
 * @author Panda
 */
public class MiniProgramResponse {

    @Getter
    @ToString(callSuper = true)
    @EqualsAndHashCode(callSuper = true)
    public static class AccessToken extends WechatHttpResponse {
        @JsonProperty("access_token")
        private final String accessToken;

        @JsonProperty("expires_in")
        private final Integer expiresIn;

        @JsonCreator
        public AccessToken(
                @JsonProperty("errcode") Integer errCode,
                @JsonProperty("errmsg") String errMsg,
                @JsonProperty("access_token") String accessToken,
                @JsonProperty("expires_in") Integer expiresIn) {
            super(errCode, errMsg);
            this.accessToken = accessToken;
            this.expiresIn = expiresIn;
        }
    }


    @Getter
    public static final class JsCode2Session extends WechatHttpResponse {

        @JsonProperty("session_key")
        private final String sessionKey;

        @JsonProperty("openid")
        private final String openId;

        @JsonProperty("unionid")
        private final String unionId;

        @JsonCreator
        public JsCode2Session(
                @JsonProperty("errcode") Integer errCode,
                @JsonProperty("errmsg") String errMsg,
                @JsonProperty("session_key") String sessionKey,
                @JsonProperty("openid") String openId,
                @JsonProperty("unionid") String unionId) {
            super(errCode, errMsg);
            this.sessionKey = sessionKey;
            this.openId = openId;
            this.unionId = unionId;
        }
    }

}
